# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
# Maintainer: Frederik Schwan <freswa at archlinux dot org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>

pkgname=streamlink
pkgver=5.4.0
pkgrel=1
pkgdesc='CLI program that launches streams from various streaming services in a custom video player (livestreamer fork)'
arch=('any')
url='https://streamlink.github.io/'
license=('BSD')
depends=("python-"{certifi,isodate,pycountry,pycryptodome,pysocks,requests,websocket-client})
checkdepends=("python-"{freezegun,pytest,pytest-asyncio,requests-mock})
makedepends=("python-"{build,installer,setuptools,versioningit,wheel})
optdepends=('ffmpeg: Required to play streams that are made up of separate audio and video streams, eg. YouTube 1080p+')
source=("https://github.com/${pkgname}/${pkgname}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.gz"{,.asc})
validpgpkeys=('E2B794C7C2C37162E5E2A097E3DB9E282E390FA0') # Streamlink Signing Key <streamlink@protonmail.com>
sha256sums=('d854348c19e032140d06ba13ee4d9b96fa838b979b689133dfd9bbdda474310b'
            'SKIP')
sha512sums=('d43bee570468320943b1d81e94b76056e5fbb000e89e72583b0bf1105822ca386c212c6480db172fbf7f43f147a9dadf8a319c0b614c66e8cf9cee75aa94020f'
            'SKIP')

build() {
  cd "$pkgname-$pkgver"
  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname-$pkgver"
  python -m installer --destdir="$PWD/tmp" dist/*.whl
  local pyver=$(python -c 'import sys;print(".".join(map(str,sys.version_info[:2])))')
  TZ=UTC PYTHONPATH="$PWD/tmp/usr/lib/python${pyver}/site-packages:$PYTHONPATH" python -m pytest
}

package() {
  cd "$pkgname-$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
